package com.shxc.smarttrade.old.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.RelativeSizeSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.shxc.smarttrade.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by jcdev1 on 2017/5/10.
 */

public class PendingOrderAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    LayoutInflater mInflater;
    Context mContext;

    public PendingOrderAdapter(Context mContext) {
        this.mContext = mContext;
        mInflater = LayoutInflater.from(mContext);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new TransactionViewholder(mInflater.inflate(R.layout.adapter_traction_product, parent, false));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        SpannableString ss = new SpannableString("1.06272");
        RelativeSizeSpan span = new RelativeSizeSpan((float) 1.5);
        ss.setSpan(span, 4, 6, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        if (holder instanceof TransactionViewholder) {
            ((TransactionViewholder) holder).tvLeft.setText(ss);
            ((TransactionViewholder) holder).tvRight.setText(ss);
        }

    }

    @Override
    public int getItemCount() {
        return 10;
    }

    public class TransactionViewholder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_left)
        TextView tvLeft;
        @BindView(R.id.tv_center)
        TextView tvCenter;
        @BindView(R.id.tv_right)
        TextView tvRight;

        TransactionViewholder(View view) {
            super(view);
            ButterKnife.bind(this, view);

        }
    }
}
